Release 10.1A: OpenEdge Development:
Progress 4GL Reference
SUBSTRING function
Extracts a portion of a character string from a field or variable.
Syntax
sourceA CHARACTER or LONGCHAR expression from which you want to extract characters or bytes.
positionAn INTEGER expression that indicates the position of the first character you want to extract from
source.lengthAn INTEGER expression that indicates the number of characters you want to extract from
source. If you do not use thelengthargument or specify -1 as the length, SUBSTRING uses the remainder of the string from the specifiedposition.typeA CHARACTER expression that directs Progress to interpret the specified
positionandlengthvalues as character units, bytes, or columns. A double-byte character registers as one character unit. By default, Progress interprets the specifiedpositionandlengthvalues as character units.There are FOUR valid types: "CHARACTER," "FIXED," "COLUMN," and "RAW." The expression "CHARACTER" specifies character units. The expression "FIXED" specifies that
Note: Ifpositionis in character units and the length is in bytes, but directs SUBSTRING to yield only whole characters. That is, if the last byte or bytes represent part of, but not all of, a multi-byte character, these bytes are excluded. The expression "COLUMN" specifies display or print character-columns. The expression "RAW" specifies bytes. If you specify thetypeas a constant expression, Progress validates the type specification at compile time. If you specify thetypeas a non-constant expression, Progress validates the type specification at run time.sourceis a LONGCHAR expression, "CHARACTER" is the only valid type and the default type. ExampleThe
r-substr.pprocedure uses the SUBSTRING function to create invoice numbers. You supply a starting invoice number. The first SUBSTRING function produces the first two characters of today’s date; the second SUBSTRING function produces the last two characters of today’s date. The procedure concatenates these four characters to a hyphen and the number you entered to produce an invoice number.
See also
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |